export 'package:practice/routers/practice_routers.dart';

import 'package:practice/constants/Constants.dart';
import 'package:practice/data/entity/organ_entity.dart';
import 'package:practice/data/entity/user_info_entity.dart';
import 'package:practice/generated/json/base/json_convert_content.dart';
import 'package:practice/manager/user_manager.dart';
import 'package:practice/net/net_utils.dart';

class Practice {
  static late PracticeResult onResult;
  ///进入云实践前调用
  static config({
    required Map<String, dynamic> user,
    required Map<String, dynamic> organ,
    required PracticeResult onResult,
    required int roleType,
    bool isDebug = false,
  }) async{
    UserManager.user = JsonConvert.fromJsonAsT<UserInfoEntity>(user);
    UserManager.organ = JsonConvert.fromJsonAsT<OrganEntity>(organ);
    UserManager.roleType = roleType;
    Constants.debug = isDebug;
    Practice.onResult = onResult;
    await NetUtils.init();
  }
}

///通知主项目回调函数
typedef PracticeResult = void Function(PracticeAction action);

///返回给主项目的事件
enum PracticeAction {
  reLogin,
}
